package com.cosina.game.crystallight.model.crystal;

import java.util.Random;

import com.cosina.game.crystallight.MediaPlayerAdapter;
import com.cosina.game.crystallight.engine.BattleEngine;

public class CrystalSeed{
	public int color;
	private int enegy = 20;
	private boolean grow = true;
	private static Random random = new Random();
	
	public CrystalSeed(int startEnegyPower){
		this.enegy = startEnegyPower*40 + 20;
		this.color = random.nextInt(4);
	}
	
	public int getEnegy(){
		if(grow){
			enegy += 20;
			if(enegy == 240){
				grow = false;
			}
		}else{
			enegy -= 20;
			if(enegy == 20){
				grow = true;
			}
		}
		return enegy;
	}
	
	public Crystal mature(){
		MediaPlayerAdapter.upgrade();
		BattleEngine.statistics.crystalCreated ++;
		Crystal crystal = CrystalFactory.create(color);
		color = random.nextInt(4);
		return crystal;
	}
}
